package com.pokermind.repository.mapper;

import com.pokermind.model.po.PokerDecisionSnapshot;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;

/**
 * PokerDecisionSnapshot 行映射器
 * 用于将ResultSet映射为PokerDecisionSnapshot实体
 * 
 * @author PokerMind Team
 */
public class PokerDecisionSnapshotRowMapper implements RowMapper<PokerDecisionSnapshot> {
    
    @Override
    public PokerDecisionSnapshot mapRow(ResultSet rs, int rowNum) throws SQLException {
        PokerDecisionSnapshot snapshot = new PokerDecisionSnapshot();
        
        // 基本字段
        snapshot.setId(rs.getLong("id"));
        snapshot.setUserId(rs.getLong("user_id"));
        snapshot.setHandId(rs.getLong("hand_id"));
        snapshot.setSnapshotSequence(rs.getInt("snapshot_sequence"));
        
        // 游戏状态
        snapshot.setGameState(rs.getString("game_state"));
        
        // AI分析结果
        snapshot.setAiRecommendation(rs.getString("ai_recommendation"));
        snapshot.setAiConfidence(rs.getBigDecimal("ai_confidence"));
        snapshot.setAiReasoning(rs.getString("ai_reasoning"));
        
        // 时间字段
        String createdAtStr = rs.getString("created_at");
        if (createdAtStr != null) {
            snapshot.setCreatedAt(LocalDateTime.parse(createdAtStr.replace(" ", "T")));
        }
        
        return snapshot;
    }
}